<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class ChessPlayer{
            constructor(name, sex){
                this.name = name;
                this.sex = sex;
                this.from = '成都'
                this.dish = ['蛋炒饭', '番茄炒蛋'] // 菜品
            }
            what(){
                console.log('棋手就是下棋的选手。一般分为职业棋手和业余棋手，其实只要有下棋行为都可以称之为棋手。')
            }
            sayHi(anotherDish, language='JavaScript'){
                // 得到会做的菜品介绍字符串
                let dishes = [...this.dish];
                dishes.push(anotherDish);
                console.log('Hi！大家好，我的名字是' + this.name);
                console.log('我来自' + this.from);
                console.log('我最喜欢的编程语言是' + language);
                console.log('我会做' + dishes.join('、'));
            }
        }
        const yuan = new ChessPlayer('源宝', 1);
        yuan.sayHi('红烧排骨');
        yuan.what();
    </script>
</body>

</html>